home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1459 < prev    next >
Encoding:
Text File  |  1996-08-05  |  869 b   |  36 lines

  1. Path: axe.netdoor.com!news
  2. From: esargent@netdoor.com (Eric Sargent)
  3. Newsgroups: comp.lang.c
  4. Subject: Q: realloc->free?
  5. Date: Sun, 14 Jan 1996 07:08:29 GMT
  6. Organization: Internet Doorway, Inc.
  7. Message-ID: <4daa2e$oh5@axe.netdoor.com>
  8. NNTP-Posting-Host: port96.netdoor.com
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11.     This is probably a dumb question, but I can't find any specific or
  12. exact information about this.  Given this:
  13.  
  14. char *a, *b;
  15.  
  16. a = malloc(10);
  17. ...
  18. /*
  19.     later we need to increase the size
  20. */
  21. ...
  22. b = realloc(a, 100);
  23.  
  24.     Now let's say realloc had to move the data so a != b.  Does realloc
  25. free the memory previously pointed to by a or should it be explicitly
  26. freed if realloc returns a new location?  I checked the FAQ, but there
  27. was nothing specific about realloc.  Thanks for any information.
  28.  
  29.  
  30. ----
  31. Eric
  32. esargent@netdoor.com
  33. http://www2.netdoor.com/~esargent
  34.  
  35.  
  36.